use dataset_representation, clear

keep if official == "DA"

local X 34_2012 35_2012 36_2012 47_2014 57_2016 62_2016 63_2016 64_2016 66_2016

local j = 1

foreach x in `X' {
	
	local mytext0
	if "`x'" == "34_2012" {
		local mytitle "Death penalty repeal"
		local mytext0 text(0.1 85 "Congruence=")
	}
	
	if "`x'" == "35_2012" local mytitle ///
		"Human trafficking increase sentences"
	if "`x'" == "36_2012" local mytitle "Soften three-strikes"
	if "`x'" == "47_2014" local mytitle ///
		"Nonviolent offenses to misdemeanors"
	if "`x'" == "57_2016" local mytitle ///
		"Increase parole for nonviolent felons"
	if "`x'" == "62_2016" local mytitle "Death penalty repeal"
	if "`x'" == "63_2016" local mytitle "Gun control"
	if "`x'" == "64_2016" local mytitle "Legalize recreational marijuana"
	if "`x'" == "66_2016" local mytitle "Death penalty speed process"

	local mysubtitle = subinstr("`x'", "_", " (", 1)
	local mysubtitle = "Prop " + "`mysubtitle'" + ")"	
	
	preserve
		
		keep if issue == "`x'"
		
		su cong
		local c = round(r(mean)*100)
		
		#delimit;
		
		gr tw
			(sc rep_ vot_, col(gray) msym(O)
				msize(small))
			(lfit rep_ vot_, col(black))
			,
				legend(off)
				name(g`j', replace)
				plotregion(style(none))
				xline(50, lpat(dash) lcol(black))
				ylab(0 "Con" 1 "Lib", angle(horiz))
				xlab(0(25)100, labsize(small))
				title(`mytitle', size(small))
				subtitle(`mysubtitle', size(small))
				xtitle("")
				ytitle("")
				`mytext0'
				text(-.2 85 "`c'%")
				;
				
		#delimit cr
		
		gr close

	restore
		
	local j = `j' + 1
	
}

gr combine g1 g2 g3 g4 g5 g6 g7 g8 g9, xcommon ycommon imargin(tiny) ///
	b1title("Voter liberalism") l1title("DA position") ///
	ysize(3) xsize(4.5)

gr export "_output/figure 3.pdf", replace
